package popcorn.ticket.serviceimpl;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import popcorn.ticket.dao.CollectionsMapper;
import popcorn.ticket.dao.MovieHallsMapper;
import popcorn.ticket.dao.MoviesMapper;
import popcorn.ticket.dao.OrdersMapper;
import popcorn.ticket.dao.TicketMapper;
import popcorn.ticket.dao.UsersMapper;
import popcorn.ticket.entity.Orders;
import popcorn.ticket.entity.Ticket;
import popcorn.ticket.service.WelComeService;
import popcorn.ticket.tool.TableList;

@Service
public class WelComeServiceImpl implements WelComeService {
	@Autowired
	private OrdersMapper om;
	@Autowired
	private TicketMapper tm;
	@Autowired
	private CollectionsMapper cm;
	@Autowired
	private UsersMapper um;
	@Autowired
	private MovieHallsMapper mhm;
	@Autowired
	private MoviesMapper mm;
	
	// 用于存储数据
	TableList tl = new TableList();
	//收获收入情况
	@Override
	public TableList<Orders> getPriceList() {
		// TODO Auto-generated method stub
		List<Orders> list = om.sltPriceList();
		// 倒序输出
		Collections.reverse(list);
		// 日期
		List<String> days = new ArrayList<String>();
		// 金额
		List<Double> price = new ArrayList<Double>();

		// 对里面的值做处理
		for (int i = 0; i < list.size(); i++) {
			// 日期存储
			days.add(list.get(i).getDays());
			// 金额存储
			price.add(list.get(i).getOrderprice());
		}
		// 存储
		tl.setData1(days);
		tl.setData2(price);

		return tl;
	}
	//电影的观影人数
	@Override
	public TableList getNumList() {
		// TODO Auto-generated method stub
		List<Ticket> list = tm.selectAllNum();

		// 电影名
		List<String> moviename = new ArrayList<String>();
		// 人数
		List<Integer> num = new ArrayList<Integer>();

		// 对里面的值做处理
		for (int i = 0; i < list.size(); i++) {
			// 电影名
			moviename.add(list.get(i).getMoviename());
			// 人数
			num.add(list.get(i).getTicketid());
		}
		// 存储
		tl.setData1(moviename);
		tl.setData2(num);

		return tl;
	}
	//电影的收藏人数
	@Override
	public TableList getCollNumList() {
		// TODO Auto-generated method stub
		List<popcorn.ticket.entity.Collections> list = cm.selectCollNum();

		// 电影名
		List<String> moviename = new ArrayList<String>();
		// 收藏人数
		List<Integer> num = new ArrayList<Integer>();

		// 对里面的值做处理
		for (int i = 0; i < list.size(); i++) {
			// 电影名
			moviename.add(list.get(i).getMovies().getMoviename());
			// 收藏人数
			num.add(list.get(i).getMovies().getMovieid());
		}
		// 存储
		tl.setData1(moviename);
		tl.setData2(num);

		return tl;
	}
	//获取用户数量
	@Override
	public int getUserNum() {
		// TODO Auto-generated method stub
		return um.selectUserNum();
	}
	//获取在映厅数
	@Override
	public int getHallsNum() {
		// TODO Auto-generated method stub
		return mhm.selectHallsNum();
	}
	//查询在映片数
	@Override
	public int getMoviesNum() {
		// TODO Auto-generated method stub
		return mm.selectMoviesNum();
	}
	//今日观影数
	@Override
	public Ticket getWatchNowNum() {
		// TODO Auto-generated method stub
		return tm.sltWatchNowNum();
	}
	//今日收入
	@Override
	public Orders getManeyNowNum() {
		// TODO Auto-generated method stub
		return om.sltManeyNowNum();
	}


}
